<?php
if ($module != ''){
    Yii::app()->layout = 'module';
}
?>
    <h3><?php echo $title; ?></h3>
    <?php
    $cs = Yii::app()->ClientScript;
    $cs->registerCoreScript('cookie');
    $cs->registerScriptFile(Yii::app()->core->AssetUrl.'/scripts/jquery/jquery.tablesorter.js', CClientScript::POS_HEAD);
    $cs->registerScriptFile(Yii::app()->core->AssetUrl.'/scripts/jquery/jquery-ui-1.7.2.interaction.min.js', CClientScript::POS_HEAD);

    if (empty($categories)):
    ?>
    <p class="msginfo">There is no category.</p>
    <?php else: ?>
    <table class="view" id="categoryList" cellpadding="0" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th class="First LeftAlign"><span>Categories</span></th>
                <th width="80px"><span>Children</span></th>
                <!-- th width="80px"><span>Order</span></th -->
                <th class="Last" width="70px"><span>Action</span></th>
            </tr>
        </thead>
        <tbody>
        <?php
        foreach ($categories as $category) :
        ?>
            <tr class="CategoryRow" id="Cat<?php echo $category->Id?>">
                <td class="CategoryTitle LeftAlign">
                    <?php echo $category->Title; ?>
                    <?php if ($category->CountChildren) : ?>
                        <a href="#" class="CategoryHandler"><img src="<?php echo Yii::app()->theme->BaseUrl;?>/images/ico-arrow-2.gif" /></a>
                    <?php else: ?>
                        <a href="#" class="CategoryHandler" style="display:none"><img src="<?php echo Yii::app()->theme->BaseUrl;?>/images/ico-arrow-2.gif" /></a>
                    <?php endif; ?>
                </td>
                <td><?php echo $category->CountChildren; ?></td>
                <!-- td><?php echo ($category->Ordering + 1); ?></td -->
                <td>
                    <a href="#" class="editCat"><img alt="icon edit" src="<?php echo Yii::app()->theme->BaseUrl ?>/images/ico-edit.gif"/></a>
                    <a href="#" class="deleteCat"><img alt="icon delete" src="<?php echo Yii::app()->theme->BaseUrl ?>/images/ico-delete.gif"/></a>
                </td>
            </tr>
        <?php
        endforeach;
        ?>
        </tbody>
    </table>

    <?php endif; //empty(categories) ?>
    <?php
        echo CHtml::submitButton('Create', array('class' => 'SmallButton', 'onclick' => 'return location="'.$this->createUrl('/Core/category/edit&module=' . $this->get('module','').'&param='.$paramName).'"')); 
    ?>
    <script type="text/javascript">
    var themeUrl = '<?php echo Yii::app()->theme->BaseUrl;?>';
    var module = '<?php echo $module; ?>';
    var rootCategroyParam = '<?php echo $paramName; ?>';
    </script>
    <?php $cs->registerScriptFile(Yii::app()->core->AssetUrl.'/scripts/category.list.js', CClientScript::POS_HEAD); ?>